package com.example.system.controller;

import com.example.common.core.controller.BaseController;
import com.example.common.core.domain.R;
import com.example.common.core.domain.TableDataInfo;
import com.example.system.domain.video.dto.VideoQueryDTO;
import com.example.system.domain.video.vo.VideoVO;
import com.example.system.service.IVideoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/video")
@Tag(name = "视频管理接口")
public class VideoController extends BaseController {

    @Autowired
    private IVideoService videoService;

    @GetMapping("/list")
    @ResponseBody
    @Operation(summary = "获取视频列表")
    public TableDataInfo getVideoList(VideoQueryDTO videoQueryDTO) {
        return getTableDataInfo(videoService.list(videoQueryDTO));
    }

    @GetMapping("/get")
    @Operation(summary = "获取视频信息")
    public R<VideoVO> get(Long videoId) {
        return R.ok(videoService.get(videoId));
    }
    
    @GetMapping("/video-stream")
    @Operation(summary = "流式播放视频")
    public R<Void> streamVideo(@RequestParam("videoId") Long videoId, HttpServletRequest httpServletRequest, HttpServletResponse response) {
        videoService.streamVideo(videoId, response);
        return R.ok();
    }
} 